﻿using DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Data;
/*************************************************************************************

     盘点相关操作  liudan add
  
*************************************************************************************/

namespace BLL
{
    public class InventoryBLL
    {
        private InventoryDAL IntDal = new InventoryDAL();

        //获取盘点单列表
        public DataSet GetInventory()
        {
            return IntDal.GetInventory();
        }
        //获取盘点单里的明细
        public DataSet GetInventoryDetail(string FBrNo)
        {
            return IntDal.GetInventoryDetail(FBrNo);
        }
        //更新盘点单明细
        public bool UpdateInventoryDetail(string FItemID, string NowNum)
        {
            return IntDal.UpdateInventoryDetail(FItemID, NowNum);
        }
        //扫码获取明细信息
        public bool GetDetailNum(string FBrNo, string PlaceBarCode, out string FItemID, out string NowNum)
        {
            return IntDal.GetDetailNum(FBrNo, PlaceBarCode, out FItemID, out NowNum);
        }

        //对盘盈的条码进行备注1121 ql
          public bool NoteCode(string FBrNo, string PkgsBarCode)
        {
            return IntDal.NoteCode(FBrNo, PkgsBarCode);
        }

       
        //完成盘点单
        public bool FinishInventory(string FBrNo,string useId, out string txt) 
        {
            bool lb_return = false;
            txt = "";
            string ls_states = IntDal.CheckStates(FBrNo);
            switch (ls_states)
            {
                case "1":
                    lb_return = IntDal.IsCheckExamine(FBrNo, out txt);
                    if (lb_return) 
                    {
                        lb_return = IntDal.ExamineCheck(FBrNo, useId);
                        if (lb_return)
                        {
                            lb_return = IntDal.FinishCheck(FBrNo, useId);
                            if (lb_return) { } else { txt = "盘点单完成失败！"; }
                        }
                        else 
                        {
                            txt = "生成损益单失败！";
                        }
                    }
                    break;
                case "2":
                    lb_return = IntDal.FinishCheck(FBrNo, useId);
                    if (lb_return) { } else { txt = "盘点单完成失败！"; }
                    break;
                case "3":
                    lb_return = false; txt = "盘点单已完成！";
                    break;
                default:                   
                    break;
            }


            return lb_return;
        }


    }
}
